package com.wisdytech.linkdcs.measuretool.action;

import com.github.pagehelper.PageInfo;
import com.wisdytech.common.bean.Filter;
import com.wisdytech.common.bean.StandardResult;
import com.wisdytech.common.bean.StandardTableResult;
import com.wisdytech.common.handler.ResourceMatchingService;
import com.wisdytech.linkdcs.measuretool.service.IMeasureRecordService;
import com.wisdytech.linkdcs.measuretool.vo.MeasureToolCheckVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhanghailin
 * @since 2018-06-15
 */
@Controller
@RequestMapping("/measureTool/measureToolCheckRecord")
public class MeasureToolCheckRecordAction {



    @Resource
    private IMeasureRecordService measureRecordService;
    @Autowired
    @Qualifier("resourceMatchingService")
    private ResourceMatchingService resourceMatchingService;
    /**
     *
     * <p>Description: 计量器具</p>
     * @param model model
     * @return String
     */
    @RequestMapping("/index")
    public String toolCheckRecordIndex(Model model, HttpServletRequest httpRequest){
        this.resourceMatchingService.getResourceName(httpRequest,model);
        return "measuretool/measureToolCheckRecord";
    }

    @RequestMapping(value = "/getMeasureToolCheckRecordList/get.mvc")
    @ResponseBody
    public StandardTableResult<MeasureToolCheckVO> getMeasureToolCheckRecordList(String measureToolCode, String measureToolName, String checkType, String supplier, String equipCode, String equipName, String checkDateStart, String checkDateEnd, Filter filter) {
        PageInfo<MeasureToolCheckVO> page = this.measureRecordService.getMeasureToolCheckRecordList(measureToolCode,measureToolName,checkType,supplier,equipCode,equipName,checkDateStart,checkDateEnd,filter);
        return new StandardTableResult<>(page.getTotal(),page.getList());
    }

    /**
     * @param pkId record primary key
     * @return StandardResult
     */
    @RequestMapping(value = "/getMeasureToolCheckResult/get.mvc")
    @ResponseBody
    public StandardResult getMeasureToolCheckResult(String pkId) {
        MeasureToolCheckVO vo = this.measureRecordService.getMeasureToolCheckResult(pkId);
        return StandardResult.getSuccessResult(vo);
    }


}
